#include "stdafx.h"

Dialog::Dialog(const std::wstring & picname, int x, int y) :x(x), y(y)
{
	image = ImageMgr::getInstance()->getImageFromName(L"img\\" + picname + L".png");

	width = image->GetWidth();
	height = image->GetHeight();
}

void Dialog::draw(Graphics * graphics)
{
	graphics->DrawImage(image, Rect(x - width*scale / 2, y - height*scale / 2, width*scale, height*scale));
}

void Dialog::update(double dtime)
{
	time += dtime;
	
	if (time <= 0.2)
	{
		scale += dtime * 4;
	}
	else if (time > 0.2 && time <= 0.3)
	{
		scale -= dtime;
	}
	else
	{
		scale = 1;
	}
}

FailDlg::FailDlg(const std::wstring & picname, int x, int y) :Dialog(picname, x, y)
{
}

int FailDlg::getcmd(int x, int y)
{
	if (x >= 104 && x <= 191 && y >= 304 && y <= 343)
	{
		return 1;
	}
	else if (x >= 223 && x <= 311 && y >= 304 && y <= 343)
	{
		return 2;
	}
	else if (x >= 341 && x <= 518 && y >= 304 && y <= 343)
	{
		return 3;
	}
	else
	{
		return 0;
	}
}

WinDlg::WinDlg(const std::wstring & picname, int x, int y)
	:Dialog(picname, x, y)
{
}

int WinDlg::getcmd(int x, int y)
{
	if (x >= 104 && x <= 191 && y >= 304 && y <= 343)
	{
		return 1;
	}
	else if (x >= 249 && x <= 335 && y >= 304 && y <= 343)
	{
		return 2;
	}
	else if (x >= 385 && x <= 516 && y >= 304 && y <= 343)
	{
		return 4;
	}
	else
	{
		return 0;
	}
}